How can I change the title of a ProgressMonitor in Java? - title

ProgressMonitor progressMonitor = new ProgressMonitor(frame, "", "", 0, 100);
progressMonitor.setProgress(0);
...
progressMonitor.setProgress(100);
This works fine for me, but now I want to change the title of this progress monitor. Currently its "Progress...".

You can set the title of the dialog window through the UIManager:
String title = "Foobar";
UIManager.put("ProgressMonitor.progressText", title);
ProgressMonitor progressMonitor = new ProgressMonitor(frame, "", "", 0, 100);
...

You can do this:
monitor.beginTask("Running Job..", IProgressMonitor.UNKNOWN);
monitor.beginTask("Job #1");
But I don't believe the actual title of the box can change.

Related

Discord .NET Value of type EmbedBuilder cannot be converted to Embed

As the title says i get "Value of type EmbedBuilder cannot be converted to Embed" error.
This is the code i'm trying right now :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
eb.Build()
Await message.Channel.SendMessageAsync("", False, eb)
OK. I found the solution. I was trying to pass the EmbedBuilder instead of Embed.
Here's my new code :
If msg.Equals("gDurum") Then
Dim eb As New EmbedBuilder With {
.Title = "Sunucu Bilgisi",
.Color = New Color(255, 0, 0),
.ImageUrl = "https://cache.gametracker.com/server_info/185.198.73.27:27015/b_560_95_1.png",
.Description = "Deneme"
}
Await message.Channel.SendMessageAsync("", False, eb.Build())
For those who are looking at the official code example might encounter type mismatch while compiling.
Make sure to build Discord.Embed into a Rich Embed which is ready to be sent.
Corrected & working code example for this:
[Command("embed")]
public async Task SendRichEmbedAsync()
{
var embed = new EmbedBuilder
{
// Embed property can be set within object initializer
Title = "Hello world!"
Description = "I am a description set by initializer."
};
// Or with methods
embed.AddField("Field title",
"Field value. I also support [hyperlink markdown](https://example.com)!")
.WithAuthor(Context.Client.CurrentUser)
.WithFooter(footer => footer.Text = "I am a footer.")
.WithColor(Color.Blue)
.WithTitle("I overwrote \"Hello world!\"")
.WithDescription("I am a description.")
.WithUrl("https://example.com")
.WithCurrentTimestamp();
await ReplyAsync(embed: embed.Build());
}

How to place QPushButton at the horizontal center of the dialog

I have a QFormLayout with a bunch of QLineEdits. I also have a QPushButton that I want to place at the horizontal center of my dialog. This is the code
//ask for book name
le_book = new QLineEdit;
layout->addRow("Book: ", le_book);
//ask for author
le_author = new QLineEdit;
layout->addRow("Author: ", le_author);
//ask for uid
le_uid = new QLineEdit;
layout->addRow("UID: ", le_uid);
//ask for tags
fillComboBox();
//ask for quantity
sb_quantity = new QSpinBox;
layout->addRow("Quantity: ", sb_quantity);
okay = new QPushButton("Okay");
connect(okay, &QPushButton::clicked, this, &Dialog::onOkay);
//how to place this pushButton at the horizontal center
Added this code after the last comment:
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(layout);
mainLayout->addWidget(okay, 0, Qt::AlignCenter);
this->setLayout(mainLayout);
And it worked!

fix footer image in tcpdf

$path = Yii::app()->basePath;
require_once($path . '/extensions/tcpdf/tcpdf.php');
$pdf = new TCPDF();
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(true);
$pdf->SetAutoPageBreak(TRUE, 0);
$pdf->AddPage();
$pdf->SetLineWidth(0.1);
$pdf->SetFont('times', '', 10);
$pdf->SetMargins(20, 20, 20, true);
$footer_image_file = Yii::app()->request->baseUrl.'/images/logo.jpg';
$content = '<div> $content </div>';
$pdf->writeHTML($content, true, false, true, false, '');
ob_end_clean();
$pdf->Output("Reports.pdf", "D");
I want to add image in fooder for every new pages.. please anyone help me...
Simply put the code displaying the image within the Footer() base method. This base method is called for any new page by either the AddPage() method and Close().
Important : The Footer method should not be called directly.
This method is supposed to be implemented in your class, so override it like this :
function Footer()
{
.... /* Put your code here (see a working example below) */
$logoX = 186; // 186mm. The logo will be displayed on the right side close to the border of the page
$logoFileName = "/images/myLogo.jpg";
$logoWidth = 15; // 15mm
$logo = $this->PageNo() . ' | '. $this->Image($logoFileName, $logoX, $this->GetY()+2, $logoWidth);
$this->SetX($this->w - $this->documentRightMargin - $logoWidth); // documentRightMargin = 18
$this->Cell(10,10, $logo, 0, 0, 'R');
}
I hope this helps and I've well understood your question.
function Footer()
{
.... /* Put your code here (see a working example below) */
$logoX = 40; //
$logoFileName = "/images/myLogo.jpg";
$logoWidth = 130; // 15mm
$logoY = 280;
$logo = $this->PageNo() . ' | '. $this->Image($logoFileName, $logoX, $logoY, $logoWidth);
$this->SetX($this->w - $this->documentRightMargin - $logoWidth); // documentRightMargin = 18
$this->Cell(10,10, $logo, 0, 0, 'C');
}
This codes are perfectly placed a image in the center of page footer.Thanks a lot pti_jul.:-)))))

How to add Code128 Barcode image to existing pdf using pdfbox(1.8.12) with barcode4j library?

I am trying to generate the barcode from barcode4j library(code128bean, other barcode beans) and try to add to the existing pdf. The barcode image is getting created locally using the below code.
//Create the barcode bean
Code128Bean code128Bean = new Code128Bean();
final int dpi = 150;
code128Bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
//width exactly one pixel
//bean.setCodeset(2);
code128Bean.doQuietZone(false);
//Open output file
File outputFile = new File("D:/barcode4jcod128.png"); //I dont want to create it
OutputStream code128Stream = new FileOutputStream(outputFile);
try {
//Set up the canvas provider for monochrome PNG output
BitmapCanvasProvider canvas1 = new BitmapCanvasProvider(
code128Stream, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
//Generate the barcode
code128Bean.generateBarcode(canvas1, "123456");
//Signal end of generation
canvas1.finish();
} finally {
code128Stream.close();
}
My problem is I don't want to create an image and save it locally in filesystem and then add it as image to pdf. I just want to create dynamically i mean just create the barcode image dynamically and add it to the pdf.
How do I set the pagesize (like PDPage.PAGE_SIZE_A4) to the existing PDPages which I retrieved from catalog.getAllPages() method, like (List<PDPage> pages = catalog.getAllPages();)
Can somebody help on this?
Thank you so much for your help Tilman. Here is what i did
public static BufferedImage geBufferedImageForCode128Bean(String barcodeString) {
Code128Bean code128Bean = new Code128Bean();
final int dpi = 150;
code128Bean.setModuleWidth(UnitConv.in2mm(1.0f / dpi)); //makes the narrow bar
code128Bean.doQuietZone(false);
BitmapCanvasProvider canvas1 = new BitmapCanvasProvider(
dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0
);
//Generate the barcode
code128Bean.generateBarcode(canvas1, barcodeString);
return canvas1.getBufferedImage();
}
// main code
PDDocument finalDoc = new PDDocument();
BufferedImage bufferedImage = geBufferedImageForCode128Bean("12345");
PDXObjectImage pdImage = new PDPixelMap(doc, bufferedImage);
PDPageContentStream contentStream = new PDPageContentStream(
finalDoc, pdPage, true, true, true
);
contentStream.drawXObject(pdImage, 100, 600, 50, 20);
contentStream.close();
finalDoc.addPage(pdPage);
finalDoc.save(new File("D:/Test75.pdf"));
The barcode is getting created the but it is created in vertical manner. i would like to see in horizontal manner. Thanks again for your help.
1) add an image to an existing page while keeping the content:
BitmapCanvasProvider canvas1 = new BitmapCanvasProvider(
dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0
);
code128Bean.generateBarcode(canvas1, "123456");
canvas1.finish();
BufferedImage bim = canvas1.getBufferedImage();
PDXObjectImage img = new PDPixelMap(doc, bim);
PDPageContentStream contents = new PDPageContentStream(doc, page, true, true, true);
contents.drawXObject(img, 100, 600, bim.getWidth(), bim.getHeight());
contents.close();
2) set the media box to A4 on an existing page:
page.setMediaBox(PDPage.PAGE_SIZE_A4);

convert HTML into word in .net application

Can anyone suggest how to show value stored in SQL in HTML form to word file. I am using open xml tool to generate my word from my asp.net MVC application and it works fine but now I am stuck in one point where there is a bullet points entry stored in my DB field and I have to show it in my table cell text property?
actual value stored in DB field: "<ul><li>tapan</li><li>gupta</li></ul><p> </p>"
Run run362 = new Run();
RunProperties runProperties358 = new RunProperties();
RunFonts runFonts851 = new RunFonts() { Hint = FontTypeHintValues.EastAsia, Ascii = "Helvetica", HighAnsi = "Helvetica", ComplexScript = "Arial" };
FontSize fontSize833 = new FontSize() { Val = "20" };
Languages languages772 = new Languages() { EastAsia = "zh-HK" };
runProperties358.Append(runFonts851);
runProperties358.Append(fontSize833);
runProperties358.Append(languages772);
Text text299 = new Text() { Space = SpaceProcessingModeValues.Preserve };
text299.Text = **my field value**
run362.Append(runProperties358);
run362.Append(text299);
Try Html to Open XML.
Refer Here : http://html2openxml.codeplex.com/
Hope this helps!